/*function ListNode(x){
    this.val = x;
    this.next = null;
}*/
function EntryNodeOfLoop(pHead)
{
    // write code here
    var fast = pHead
    var slow = pHead
    while(fast !== null && fast.next !== null){
      fast = fast.next.next
      slow = slow.next
      if(fast === slow){
        while(pHead !== slow){
          pHead = pHead.next
          slow = slow.next
        }
        return pHead
      }
    }
    return null
}
module.exports = {
    EntryNodeOfLoop : EntryNodeOfLoop
};